﻿using System;

namespace Dotnet.Utils.Utility.Dependency.Castle
{
    public static class IocHelper
    {
        public static void Register(Type type, Type impl)
        {
            IocManager.Instance.Register(type, impl, DependencyLifeStyle.Singleton);
        }

        public static void Register(Type type, Type impl, DependencyLifeStyle lifeStyle)
        {
            IocManager.Instance.Register(type, impl, lifeStyle);
        }

        public static void Register<TType, TImpl>() where TType : class where TImpl : class, TType
        {
            IocManager.Instance.Register<TType, TImpl>(DependencyLifeStyle.Singleton);
        }

        public static void Register<TType, TImpl>(DependencyLifeStyle lifeStyle) where TType : class where TImpl : class, TType
        {
            IocManager.Instance.Register<TType, TImpl>(lifeStyle);
        }

        public static void RegisterSingleton(Type type, object impl)
        {
            IocManager.Instance.RegisterSingleton(type, impl);
        }

        public static T Resolve<T>()
        {
            return IocManager.Instance.Resolve<T>();
        }

        public static object Resolve(Type type)
        {
            return IocManager.Instance.Resolve(type);
        }
    }
}